/**
 * @author luoqingbo
 * @create 2024/4/28 10:10
 */
public class Leetcode1017 {

    public static void main(String[] args) {
        System.out.println(baseNeg2(0));
        System.out.println(baseNeg2(3));
        System.out.println(baseNeg2(4));
    }

    public static String baseNeg2(int n) {
        if (n == 0) {
            return "0";
        }
        String res = "";
        while (n != 0) {
            int x = n % (-2);
            if (x == 0) {
                res = "0" + res;
            } else {
                n -= 1;
                res = "1" + res;
            }
            n = n / (-2);
        }
        return res;
    }
}
